package com.sfd.thriftclient;

import java.util.List;

import org.apache.hadoop.hive.service.HiveClient;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
public class ThriftClient {
	public static void main(String[] args) throws Exception {
		//创建socket：链接
		TSocket socket=new TSocket("192.168.3.18", 10000);
		//创建一个协议
		TProtocol prot=new TBinaryProtocol(socket);
		//创建hive client
		HiveClient client=new HiveClient(prot);
		//打开socket
		socket.open();
		//执行HQL
		client.execute("show tables");
		//处理结果
		List<String> list=client.fetchAll();
		for(String s:list){
			System.out.println(s);
		}
	
	}
}
